package com.charles.seckillPlatform.service.impl;

import cn.hutool.core.util.PhoneUtil;
import com.charles.seckillComponentCommon.exceptions.ServiceException;
import com.charles.seckillComponentCommon.utils.StringUtils;
import com.charles.seckillData.domain.SysAddr;
import com.charles.seckillPlatform.service.SysAddrService;
import org.springframework.stereotype.Service;

@Service
public class SysAddrServiceImpl implements SysAddrService {

    @Override
    public void checkAddrForm(SysAddr sysAddr) {

        if (StringUtils.isEmpty(sysAddr.getReceiver())
                || StringUtils.isEmpty(sysAddr.getPhone())
                || StringUtils.isEmpty(sysAddr.getLocation())
                || StringUtils.isEmpty(sysAddr.getFull_addr())) {
            throw new ServiceException("请完善表单信息");
        }

        if (!PhoneUtil.isMobile(sysAddr.getPhone())) {
            throw new ServiceException("手机号码格式不合法");
        }

    }

}
